<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>tueye作品管理-tueye作品管理-tueye专业的图片欣赏交流社区</title>
		
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/themes/flexigrid/css/flexigrid.css" />
		<script type="text/javascript" src="<%=request.getContextPath() %>/script/jquery.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath() %>/script/grid/flexigrid.js"></script>
		<style type="text/css" media="all"> 
			@import "<%=request.getContextPath() %>/themes/flexigrid/css/thickbox.css"; 
		</style>
		<link rel="alternate stylesheet" type="text/css" href="<%=request.getContextPath() %>/themes/flexigrid/css/1024.css" title="1024 x 768" />
		<script src="<%=request.getContextPath() %>/script/grid/thickbox.js" type="text/javascript"></script>
		<style>
			.flexigrid div.fbutton .add {
				background: url(<%=request.getContextPath() %>/themes/flexigrid/images/add.png) no-repeat center left;
			}
			
			.flexigrid div.fbutton .delete {
				background: url(<%=request.getContextPath() %>/themes/flexigrid/images/close.png) no-repeat center left;
			}
			.flexigrid div.fbutton .edit {
				background: url(<%=request.getContextPath() %>/themes/flexigrid/images/plugin.gif) no-repeat center left;
			}
			.flexigrid div.fbutton .copy {
				background: url(<%=request.getContextPath() %>/themes/flexigrid/images/copy.gif) no-repeat center left;
			}
		</style>

	</head>

	<body>
	
	<div class="bborderx">
		<table id="flex1" style="display:none"></table>
	</div>
	 
	 
	<div style="display:none;">
		<input type="button" id="errorrain" href="<%=request.getContextPath() %>/common/delErro.html?height=200&amp;width=300" title="出错信息！" class="thickbox" value="" />
	</div>		
		<script type="text/javascript">
			$("#flex1").flexigrid
			(
			{
			url: '<%=request.getContextPath() %>/topicNearFuture.do',
			dataType: 'json',
			errormsg: '连接错误！',
			colModel : [
				{display: '主键', name : 'id', width : 60, sortable : true, align: 'left',hide: true},
			    {display: '编号', name : 'numid', width : 30, sortable : true, align: 'center'},
				{display: '作品标题', name : 'topic_title', width : 240, sortable : true, align: 'center'},
				{display: '作品作者', name : 'topic_author', width : 60, sortable : true, align: 'left'},
				{display: '发布时间', name : 'sys_time', width : 120, sortable : true, align: 'left'},
			    {display: '点击次数', name : 'topic_clickCount', width : 60, sortable : true, align: 'left'},
			    {display: '转自', name : 'topic_from', width : 60, sortable : true, align: 'left'},
			    {display: '所属类型', name : 'topictype', width : 60, sortable : true, align: 'left'},
			    {display: '查看', name : 'viewall', width : 30, sortable : true, align: 'left'},
			    {display: '审核', name : 'auditing', width : 30, sortable : true, align: 'left'}
				],
			buttons : [
				{name: '增加', bclass: 'add', onpress : exOperation}, 
				{name: '修改', bclass: 'edit', onpress : exOperation},
				{name: '删除', bclass: 'delete', onpress : exOperation},
				{separator: true}
				],
			searchitems : [
				{display: '作品标题', name : 'topic_title', isdefault: true},
				{display: '主健', name : 'id'}
				],
			sortname: "id",
			sortorder: "asc",
			usepager: true,
			title: 'tueye作品管理',
			useRp: true,
			singleSelect: false,
			ifDblclick: false,
			rp: 10,
			showTableToggleBtn: true,
			width: 850,
			height: 400
			}
			);
			
			//操作数据
			function exOperation(com,grid){
				if (com=='删除'){
					if( $('.trSelected',grid).length>0){
						if(confirm('是否删除这 ' + $('.trSelected',grid).length + ' 条记录吗?')){
							  var  id ="";
							  //debugger;
						     for(var i=0;i<$('.trSelected',grid).length;i++){
						        id += "id="+$('.trSelected',grid).find("td:first").eq(i).text()+"&";
						     }
						      $.ajax({ 
								url: "<%=request.getContextPath()%>/topiclist.do" ,
								type:'post', 
								dataType:'action', 
								data: id ,  
								success:update_page
	           					}); 
	          				}
					 }else{
					   alert("请选择某行删除！");
					 }
				}else if (com=='增加'){
					 OpenWin('<%=request.getContextPath() %>/publish.do',600,800);
					 
				}else if(com == '修改'){
				
					if( $('.trSelected',grid).length>0){
						  
						  if($('.trSelected',grid).length>0&&$('.trSelected',grid).length>1){
						  	alert("不能选择多行！请选择一行数据进行修改！");
						  }
						  
						  var  id = $('.trSelected',grid).find("td:first").eq(0).text();
						 	window.location.href="<%=request.getContextPath()%>/adsite.do?action=initDetail&id="+id+"&type=edit";

					 }else{
					   alert("请选择某行数据修改！");
					 }
					 
				}else if(com == '复制'){
					
				}			
			}
			
			function update_page(obj) {
				if(obj=='true'){
		         	window.location.reload();
		         }else{
		         	$('#errorrain').trigger("click");
		         }
	     	} 	
	     　   function OpenWin(theUrl,width,heigh)
			 {
  					window.open(theUrl,'','menubar=no, z-look=yes, scrollbars=yes, toolbar=no, status=yes, resizable=no, width='+ width +', height='+heigh);
			 }
	      function issuance(topicid){
	     	$.ajax({ 
				url: "<%=request.getContextPath()%>/createList.do",
				type:'post', 
				dataType:'action', 
				data: topicid ,  
				success:update_page
        					}); 
	     }
	</script>
	<div style="display:none;">
		<input type="button" id="editrain" href="<%=request.getContextPath() %>/common/delErro.html?height=200&amp;width=300" title="出错信息！" class="thickbox" value="" />
	</div>	
	</body>
</html>
